package demo;

import java.util.Scanner;

public class Demo2 {
    private static volatile boolean flag=true;

    public static void main(String[] args) {
        Thread t1=new Thread(()->{
//            while(flag){
//                try {
//                    Thread.sleep(1);
//                } catch (InterruptedException e) {
//                    throw new RuntimeException(e);
//                }
//            }
            System.out.println("t1线程已经结束");
        });
        Thread t2=new Thread(()->{
            Scanner sc=new Scanner(System.in);
            System.out.println("输入任意内容以结束线程t1:");
            sc.next();
            flag=false;
        });
        t1.start();
        t2.start();
    }
}
